import _ from "lodash"
import cfg from "../../../lib/config/config.js"
import { Common } from "#miao"

export default class base {
  constructor(e = {}) {
    this.e = e
    this.userId = e?.user_id
    this.model = "BH3-Plugin"
    this._path = process.cwd().replace(/\\/g, "/")
  }

  get prefix() {
    return `Yz:BH3:${this.model}:`
  }

  async renderImg(tpl, data, cfg = {}) {
    return Common.render("BH3-Plugin", `html/${tpl}`, data, {
      ...cfg,
      e: this.e,
    })
  }

  /**
   * 截图默认数据
   * @param saveId html保存id
   * @param tplFile 模板html路径
   * @param pluResPath 插件资源路径
   */
  get screenData() {
    let yunzaiName = cfg.package.name
    if (yunzaiName == "miao-yunzai") {
      yunzaiName = "Miao-Yunzai"
    } else if (yunzaiName == "yunzai") {
      yunzaiName = "Yunzai-Bot"
    } else if (yunzaiName == "trss-yunzai") {
      yunzaiName = "TRSS-Yunzai"
    } else {
      yunzaiName = _.capitalize(yunzaiName)
    }
    let data = {
      saveId: this.userId,
      cwd: this._path,
      yzVersion: `v${cfg.package.version}`,
      yzName: yunzaiName,
    }
    return {
      ...data,
      tplFile: `./plugins/BH3-Plugin/resources/html/${this.model}/${this.model}.html`,
      pluResPath: `${this._path}/plugins/BH3-Plugin/resources/`,
      game: "bh3",
    }
  }
}
